package com.rongcheng.applibs;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;

import com.rongcheng.applibs.talking_data.TalkingDataConfig;
import com.tendcloud.tenddata.TCAgent;

/**
 * Created by frc on 16-9-26.
 */

public abstract class BaseActivity extends FragmentActivity {
    protected Context mContext;
    protected String TAG;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = this;
        TAG = this.getClass().getSimpleName();

        setContentView(setLayoutId());
        initView();
        initData();
        initListener();
    }

    protected abstract int setLayoutId();


    protected abstract void initView();

    protected abstract void initData();

    protected abstract void initListener();

    @Override
    protected void onResume() {
        super.onResume();
        Log.e(TAG,"onResume::: "+TalkingDataConfig.getInstance().getActivityMap().get(TAG));
        TCAgent.onPageStart(mContext,TalkingDataConfig.getInstance().getActivityMap().get(TAG));
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e(TAG,"onDestroy::: "+TalkingDataConfig.getInstance().getActivityMap().get(TAG));
        TCAgent.onPageEnd(mContext,TalkingDataConfig.getInstance().getActivityMap().get(TAG));
    }

    @Override
    protected void onPause() {
        super.onPause();
        TCAgent.onPause(this);
    }
}
